package com.laan.plat;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.RectF;
import android.util.Log;

public class Objecte {
	public static float GRAV = 0.5f;
//	public float x;
//	public float y;
//	public float width;
//	public float height;
	public RectF rec;
	
	public float vx;
	public float vy;
	public float g;
	public Bitmap img;
	
	public Objecte() {
		Log.i("Objecte", "Prota?!");
	}
	
	public Objecte(Bitmap bm, float nx, float ny, float ntx, float nty, float nvx, float nvy) {
		rec = new RectF(nx, ny, nx + ntx, ny + nty);
//		x = nx;
//		y = ny;
//		width = ntx;
//		height = nty;
		vx = nvx;
		vy = nvy;
		g = 0f;
		if(bm != null) img = Bitmap.createScaledBitmap(bm,(int)rec.width(),(int)rec.height(),false);
	}
	
	public void setBitmap(Bitmap bm) {
		img = Bitmap.createScaledBitmap(bm,(int)rec.width(),(int)rec.height(),false);
	}
	
	public void enableGravity() {
		g = GRAV;
	}
	
	public void actualitza() {
//		x += vx;
//		y += vy;
		rec.offset(vx, vy);
		vy += g;
	}
	
	public void draw(Canvas canvas) {
		canvas.drawBitmap(img, rec.left - GV.Game.offsetX, rec.top, null);
	}
	
	public void draw(Canvas canvas, float offsetY) {
		canvas.drawBitmap(img, rec.left - GV.Game.offsetX, rec.top - offsetY, null);
	}
}
